package com.teckteam.ptvsystem.controller;

import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import com.teckteam.ptvsystem.view.GeocodeResultRowPanel;

/**
 * Custom Mouse Listener for single row of Geocode results
 *
 */
public class GeocodeResultsML extends MouseAdapter
{
   private boolean hovered = false;
   private Color defColor;
   private GeocodeResultRowPanel grrp;
   
   /**
    * Constructor, provided with row panel instance. 
    * 
    * @param grrp
    */
   public GeocodeResultsML(GeocodeResultRowPanel grrp)
   {
      this.grrp = grrp;
      this.defColor = grrp.getBackground();
   }
   
   public void mousePressed(MouseEvent e)
   {
      if(hovered)
         grrp.setBackground(Color.GREEN);
      
   }
   
   public void mouseReleased(MouseEvent e)
   {
      if(hovered)
         grrp.setGPSCoords();
      else
         grrp.setBackground(defColor);
   }
   
   public void mouseEntered(MouseEvent e)
   {
      hovered = true;
      grrp.setBackground(Color.YELLOW);
   }
   
   public void mouseExited(MouseEvent e)
   {
      grrp.setBackground(defColor);
      hovered = false;
   }
}
